/*
Copyright (C) 2012 Brady Vidovic

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package xmltvdb.tools;

import btv.logger.BTVLogLevel;
import btv.logger.BTVLogger;

import btv.logger.BTVLoggerOptions;
import btv.tools.BTVConstants;
import btv.tools.BTVTools;
import java.io.File;

/**
 *
 * @author bvidovic
 */
public class Constants extends BTVConstants
{
        
    
    public static Config Config = null;
    public static File CACHE_DIR = null;
    public static File XMLTVS_DIR = null;
    /**
     * Single Instance constructor.. 
     * If singleInstance is true, limits to single instance of this program, based on binding to singleInstancePort
     * @param singleInstance Set to true to limit to single instance
     * @param singleInstancePort Port to bind to 
     * @param singleInstanceTimeoutSec Seconds to wait for other instance to finish before proceeding. <0 means wait forever
     */
    public Constants(String propertiesFileName, BTVLogLevel logLevel, boolean singleInstance, int singleInstancePort, int singleInstanceTimeoutSec)
    {        
        super(Constants.class,new BTVLoggerOptions()
                .setSingleInstance(true, singleInstancePort, singleInstanceTimeoutSec)
                .setLevelToLogAt(logLevel)
                .setLogToCurrentFile(true)
                .setLogToHistoryFile(true)
                .setLogToSystemOut(true))
               ;        
        setTestingIfComputerNameIs("bvidovic11l");
        
        if(TESTING)
        {            
            BASE_DIR = BASE_DIR.getParentFile();
            Logger.INFO("TESTING = "+TESTING+", BASE_DIR is now: "+ BASE_DIR.getAbsolutePath());            
        }
        
        //load config            
        Config = new Config(new File(BASE_DIR, propertiesFileName));
                    
        
        //create cached dir if it doesnt exist    
        CACHE_DIR = new File(BASE_DIR.getAbsolutePath(),"cache");            
        if(!CACHE_DIR.exists()) CACHE_DIR.mkdir();            
        
        XMLTVS_DIR = new File(BASE_DIR.getAbsolutePath(),"xmltvs");        
        if(!XMLTVS_DIR.exists()) XMLTVS_DIR.mkdir();        
                
        //over-ride any super static variables here
        //ENCODING_FORMAT="xxx";        
    }            
     
    //static final            
    public static final String TVDB_API_KEY = "05EB6802977A1FFE";
    public static final String IMDB_IDENTIFIER = "imdbid";//identifier used by TheTVDB.com
    public static final String ZAP2IT_IDENTIFIER = "zap2it";//identifier used by TheTVDB.com
    
    
    //static defaults        
    public static String STOP_FILE_NAME = "DELETE_ME_TO_STOP_XMLTVDB_LISTENER";        
                  
}